from elasticsearch import Elasticsearch
class Myes:
    def __init__(self,name,type):
        self.es = Elasticsearch(hosts='127.0.0.1')
        self.index_name=name
        self.index_type=type

    def insert(self,data):
        self.es.index(index=self.index_name,doc_type=self.index_type,body=data)

    def search(self,query):
        body={'query':query}
        mes = self.es.search(index=self.index_name,body=body)
        return mes